/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * Project Name: lmrp-android app
 * Create Time: 16-2-16 下午6:47
 */

package com.lenovo.mso2o.view.timepicker;

/**
 * Range for visible items.
 */
public class ItemsRange {
	// First order_item number
	private int first;

	// Items count
	private int count;

	/**
	 * Default constructor. Creates an empty range
	 */
	public ItemsRange() {
		this(0, 0);
	}

	/**
	 * Constructor
	 * 
	 * @param first
	 *            the number of first order_item
	 * @param count
	 *            the count of items
	 */
	public ItemsRange(int first, int count) {
		this.first = first;
		this.count = count;
	}

	/**
	 * Gets number of first order_item
	 * 
	 * @return the number of the first order_item
	 */
	public int getFirst() {
		return first;
	}

	/**
	 * Gets number of last order_item
	 * 
	 * @return the number of last order_item
	 */
	public int getLast() {
		return getFirst() + getCount() - 1;
	}

	/**
	 * Get items count
	 * 
	 * @return the count of items
	 */
	public int getCount() {
		return count;
	}

	/**
	 * Tests whether order_item is contained by range
	 * 
	 * @param index
	 *            the order_item number
	 * @return true if order_item is contained
	 */
	public boolean contains(int index) {
		return index >= getFirst() && index <= getLast();
	}
}